package com.googlecode.likesql.converter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import com.googlecode.likesql.constant.SqlChar;
import com.googlecode.likesql.constant.SqlConstant;

/**
 * @author Johny Huang
 *
 */
public class DateConverter implements Converter {
	
	public String toTemplate(Object obj) {
		return String.valueOf(SqlConstant.CHAR_FOR_REPLACE);
	}
	
	public String toSql(Object obj){
		Date date=(Date)obj;
		SimpleDateFormat df=new SimpleDateFormat("YYYY-MM-DD HH:MM:SS");
		return SqlChar.QUOTE+df.format(date)+SqlChar.QUOTE;
	}

	public List toValueList(Object obj) {
		LinkedList list=new LinkedList();
		list.add(obj);
		return list;
	}
}
